package com.siburian.MyStuff;

import java.util.ArrayList;

import com.kidroid.kichart.ChartActivity;
import com.kidroid.kichart.model.Aitem;
import com.kidroid.kichart.view.LineView;
import android.graphics.Color;
import android.os.Bundle;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class StatistikAnak extends ChartActivity{
	LineView lv = null;
	public int durationToast1 = 1000;
	String[] test;
	float[] scoreProfile;
	Profil_Stat statistikProfil;
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		statistikProfil = new Profil_Stat(this);
		ArrayList<ArrayList<Object>> data = statistikProfil.getProfile(ListProfil.profileID, ChooseKelas.kelasSiswa, ListBelajar.typeStudy, ListBab.idBab);
		test = new String[data.size()];
        for (int posisi = 0; posisi < data.size(); posisi++) {
        	ArrayList<Object> baris = data.get(posisi);
        	test[posisi] = baris.get(2).toString();
        }
        
        scoreProfile = new float[data.size()+1];
        String beginPoint = "0";
        scoreProfile[0] = Float.parseFloat(beginPoint);
        for (int pos = 0; pos < data.size(); pos++) {
        	scoreProfile[pos+1] = Float.parseFloat(test[pos]); 
        }
		String[] arrX = new String[data.size()+1];
		for(int pos = 0; pos < data.size()+1; pos++){
			arrX[pos] = "ujian "+ pos;
		}
		if(data.size() == 0){
			Toast toast = new Toast(getBaseContext());
			toast.makeText(getBaseContext(),"Data di Belum ada silahkan mengerjakan Test Terlebih dahulu", Toast.LENGTH_LONG).show();

		}		

		Aitem[] items = new Aitem[1];
		items[0] = new Aitem(Color.RED, "Nilai Test", scoreProfile);
//		items[1] = new Aitem(Color.GREEN, "Income", arr2);
		lv = new LineView(this);
		lv.setTitle("Perkembangan Belajar anak");
		lv.setAxisValueX(arrX);
		lv.setItems(items);
		setContentView(lv);

	}
}
